Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: major refactor of dc6 package #1

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

gucio321
Copy link

@gucio321 gucio321 commented Aug 19, 2021

Hi,
some time ago I attempted to refactor d2dc6 package (see https://github.com/gucio321/d2dc6).
In this PR i'm merging the changes, I did.
changelog:

  • add readme
  • add docs dir
  • merge gucio321/d2dc6 refactors
    • split main package into two smaller (extract dc6Frames pkg)
    • put appropriate parts of decoder in a new frames package
    • remove unnecessary fields from both structures (dc6 and dc6Frame)
    • TODO: add encoder (need to rewrite to use gravestench/bitstream)

I hope, that these changes will make the code faster and cleaner.

README.md Outdated Show resolved Hide resolved
cmd/dc6-view/main.go Outdated Show resolved Hide resolved
Comment on lines -1 to -2
// Package dc6 provides a DC6 animation decoder, used by diablo 2.
package dc6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we delete this file, then?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure. I suppose that if there are no go package in main dir, this file isn't necessary.
It could be inside of pkg dir

Directions []*Direction
palette color.Palette
}
Termination [terminationSize]byte
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these termination bytes are also artifacts of the encoding, and likely not needed in the decoded struct.

Copy link
Author

@gucio321 gucio321 Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is, that this value isn't the same in certain dc6 files.
from documentation, we can see, that:

 UBYTE termination[4]; // EE EE EE EE or CD CD CD CD 

and it may be of importance for d2 game

pkg/dc6.go Outdated Show resolved Hide resolved

for dir := 0; dir < d.Frames.NumberOfDirections(); dir++ {
for f := 0; f < d.Frames.FramesPerDirection(); f++ {
err = d.Frames.Direction(dir).Frame(f).Load(r, &d.palette)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this.

Why would you need to pass the palette in?

Why is the palette a data member of each frame?

The DC6 should only have a single palette, and the frames should not need a palette to be loaded...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please note that it is a pointer to the palette used by dc6, not palette itself.

Maybe the better solution is to add (*Frame).Palette method to set it?

pkg/frames/frame.go Outdated Show resolved Hide resolved
palette *color.Palette

FrameData []byte
Terminator []byte
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an artifact of the encoding, we don't need to store the termination bytes.

@gucio321
Copy link
Author

@gravestench thanks for your reviews! just fixed most of them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants